#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
#include<stdlib.h>
#define MAX 1000
typedef struct LNode1
{
	int data[MAX];
	int top;
}stack1;
typedef struct LNode2
{
	char data[MAX-1];
	int top;
}stack2;
int main()
{
	stack1* s; 
	stack2* op;
	s = (stack1*)malloc(sizeof(stack1));
	s->top = -1;
	op = (stack2*)malloc(sizeof(stack2));
	op->top = -1;
	int n;
	scanf("%d", &n);
	int s1;
	char s2;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &s1);
		s->data[++s->top] = s1;
	}
	for (int i = 0; i < n - 1; i++)
	{
		getchar();
		scanf("%c", &s2);
		op->data[++op->top] = s2;
	}
	while (s->top != 0)
	{
		if (op->data[op->top] == '+')
		{
			s->data[s->top - 1] = s->data[s->top] + s->data[s->top - 1];
		}
		else if(op->data[op->top] == '-')
		{
			s->data[s->top - 1] = s->data[s->top-1] - s->data[s->top];
		}
		else if (op->data[op->top] == '*')
		{
			s->data[s->top - 1] = s->data[s->top] * s->data[s->top - 1];
		}
		else
		{
			if(s->data[s->top]!=0)
				s->data[s->top - 1] = s->data[s->top-1] / s->data[s->top];
			else
			{
				printf("ERROR: %d/0\n",s->data[s->top-1]);
				return 0;
			}
		}
		s->top--;
		op->top--;
	}
	printf("%d\n", s->data[s->top]);
	return 0;
}